package com.java.base.exercise.current.entity;

import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

/**
 * @Author RenPu
 * @Date 2022/1/8 17:18
 * @Version 1.0
 * @Description: Promis模式
 **/
public class Promise {

    public FutureTask<Object> create(long startTime){

        FutureTask<Object> futureTask=new FutureTask<Object>(()->{

            System.out.println("开始烧水.......");
            BoilWater boilWater = new BoilWater();
            Thread.sleep(15000);
            boilWater.setStatus(true);
            return boilWater;
        });

        new Thread(futureTask).start();  //异步执行此任务

      return futureTask;
    }
}
